﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHZY.Business.Interfaces;
using SHZY.DependencyInjection;
using SHZY.TaskScheduler;

namespace SHZY.Business.TimeTask
{
    public class IQCConfirmInspectionTask : ISpareTimeWorker
    {
        /// <summary>
        /// 来料检验自动合批并确认生成检验批.
        /// </summary>
        /// <param name="timer">参数</param>
        /// <param name="count">次数</param>
        [SpareTime("* * * * * ?", "来料检验自动合批并确认生成检验批", ExecuteType = SpareTimeExecuteTypes.Serial)]
        public void GenerateInspection(SpareTimer timer, long count)
        {
            // 创建作用域
            Scoped.Create(async (factory, scope) =>
            {
                var sqlSugarRepository = App.GetService<IQmsBusiInspectionService>(scope.ServiceProvider);
                await sqlSugarRepository.AutoGenerateInspection();
            });
        }
    }
}
